<!DOCTYPE html>
<html>
<head>
  <meta charset="<?php echo $cfg_soft_lang; ?>">
  <title>模块管理</title>
  <link rel="stylesheet" href="../static/web/css/bootstrap.min.css">
  <link rel="stylesheet" href="../static/web/font/css/font-awesome.min.css">
  <link rel="stylesheet" href="../static/web/css/admin.css">
  <script src="../static/web/js/jquery.min.js"></script>
  <script src="../static/web/js/bootstrap.bundle.min.js"></script>
  <script src="../static/web/js/webajax.js"></script>
  <script>
    function getmodule(action, hash) {
      $DE('status_' + hash).innerHTML = '<img src=\'../static/web/img/loadinglit.gif\'>';
      fetch('module_main.php?action=download&hash=' + hash).then(resp=>resp.text()).then((d)=>{
        $DE('status_' + hash).innerHTML = d;
      });
      $DE('manager_' + hash).style.display = 'block';
    }
  </script>
</head>
<body>
  <div class="alert alert-info maintable" style="margin:12px auto">DedeBIZV6开始启动<a href="<?php echo $cfg_biz_dedebizUrl; ?>/license_developer" target="_blank">DedeBIZ商业开发者计划</a>，为了保障系统及技术服务安全，请认准DedeBIZ商业认证开发者</div>
  <table width="98%" cellpadding="1" cellspacing="1" align="center" class="table maintable">
    <form name="form1" action="plus_add.php" method="post">
      <input type='hidden' name='dopost' value='save'>
      <tr>
        <td height="26" colspan="7" background="../static/web/img/tbg.gif" style="padding-left:10px">
          <div style="float:left"><a href='module_main.php'>模块管理</a> &gt; 模块列表</div>
          <div style="float:right;padding-right:10px">
            <a class="btn btn-success btn-sm" href="module_main.php">全部</a>
            <a class="btn btn-success btn-sm" href="module_main.php?moduletype=soft">模块</a>
            <a class="btn btn-success btn-sm" href="module_main.php?moduletype=templets">模板</a>
            <a class="btn btn-success btn-sm" href="module_main.php?moduletype=plus">小插件</a>
            <a class="btn btn-success btn-sm" href="module_main.php?moduletype=patch">补丁</a>
          </div>
        </td>
      </tr>
      <tr bgcolor="#F8FCF1">
        <td align="center" width="16%">模块名称</td>
        <td align="center" width="12%">发布时间</td>
        <td align="center" width="10%">编码</td>
        <td align="center" width="10%">类型</td>
        <td align="center" width="12%">模块状态</td>
        <td align="center" width="26%">管理</td>
      </tr>
      <?php
      if(count($modules)>0)
      foreach($modules as $k=>$v)
      {
      ?>
      <tr height="26" align="center" onmousemove="javascript:this.bgColor='#F8FCF1';" onmouseout="javascript:this.bgColor='#ffffff';">
        <td><?php echo $v['name']; ?></td>
        <td><?php echo $v['time']; ?></td>
        <td>
        <?php
      	if($cfg_soft_lang != $v['lang']) echo "<span style='color:#dc3545'>".$v['lang']."</span>";
      	else  echo $v['lang'];
        ?>
        </td>
        <td><?php echo $types[$v['moduletype']]; ?></td>
        <td>
        <?php
		    $file = DEDEDATA."/module/{$v['hash']}.xml";
		    if(file_exists($file)) {
			    if(file_exists(DEDEDATA."/module/{$v['hash']}-readme.php")){
				    echo "已安装 <a class='text-danger' href='module_main.php?action=uninstall&hash={$v['hash']}'>卸载</a>";
			    } else {
				    echo "未安装 <a class='text-success' href='module_main.php?action=setup&hash={$v['hash']}'>安装</a>";
			    }
		    } else {
			    echo "<div id=\"status_{$v['hash']}\"><a class=\"text-danger\" href=\"javascript:getmodule('download','{$v['hash']}')\">下载</a></div>";
        }
        ?>
        </td>
        <td>
          <div id='manager_<?php echo $v['hash']; ?>'<?php if(!file_exists(DEDEDATA."/module/{$v['hash']}.xml")) echo 'style="display:none"'?>>
            <a class="btn btn-success btn-sm" href="module_main.php?action=view_developoer&hash=<?php echo $v['hash']; ?>">开发者</a>
            <a class="btn btn-success btn-sm" href="module_main.php?action=showreadme&hash=<?php echo $v['hash']; ?>">说明</a>
            <a class="btn btn-success btn-sm" href="module_main.php?action=view&hash=<?php echo $v['hash']; ?>">详情</a>
            <a class="btn btn-success btn-sm" href="module_main.php?action=edit&hash=<?php echo $v['hash']; ?>">修改</a>
            <a class="btn btn-danger btn-sm" href="module_main.php?action=del&hash=<?php echo $v['hash']; ?>">删除</a>
          </div>
        </td>
      </tr>
      <?php
      }
      ?>
      <tr>
        <td colspan="7" bgcolor="#f8f8f8" align="center"></td>
      </tr>
    </form>
  </table>
</body>
</html>